import Vue from 'vue';
import App from './App';
import router from './router';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-default/index.css';    // 默认主题
import "babel-polyfill";

import api from './utils/api.js';
import req from './utils/req.js';
import sign from './utils/sign.js';
import cache from './utils/cache.js'
import md5 from './utils/md5.js';

Vue.prototype.$req = req.Req;
Vue.prototype.$api = api.Api;
Vue.prototype.$prefix = api.Prefix();
Vue.prototype.$sign = sign.getSign;
Vue.prototype.$cache = cache.cache;
Vue.prototype.$md5 = md5.hex_md5;
Vue.prototype.$size = 10;

Array.prototype.unique = function()
{
    var n = {},r=[]; //n为hash表，r为临时数组
    for(var i = 0; i < this.length; i++) //遍历当前数组
    {
        if (!n[this[i]]) //如果hash表中没有当前项
        {
            n[this[i]] = true; //存入hash表
            r.push(this[i]); //把当前数组的当前项push到临时数组里面
        }
    }
    return r;
}

Vue.use(ElementUI);

new Vue({
    router,
    render: h => h(App)
}).$mount('#app');
